exports.title = '按照设备mac编码查询终端信息';
exports.path = '/wzkc/terminal/queryByMac';
exports.pool = 'task';

exports.sqltext = `select a.*, case when sysdate < a.valid_date then '在保' else '超保' end as 是否超保,
(select s.res_state from ucr_cen1.td_s_resstate s where s.res_type_code = '4' and s.res_state_code = a.TERMINAL_STATE) as 库存状态,
(select m.terminal_model_desc from uop_cen1.td_s_terminal_model m where m.terminal_model_code = '103118') as 终端型号
 from tf_r_terminal_arch a where a.terminal_id=:mac
`;


// 请求范例，用于调用者了解请求数据结构，也用于系统自动内测发起请求
exports.request = {
  mac: '30F31D843655',
};

exports.outConverter = (sqlresult) => {
  const data = sqlresult.rows[0];
  if (!data) {
    throw new Error('无匹配记录');
  }
  return data;
};
